package com.audaque.springboot.foshanupload.web.esdatademo.model.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author zgb
 * @desc ...
 * @date 2023-04-19 17:30:42
 */

//indexName名字如果是字母那么必须是小写字母
@Data
@AllArgsConstructor
@NoArgsConstructor
@Document(indexName = "student", shards = 1, replicas = 1)
public class StudentPojo  implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    private String id;

    @Field(store = true, type = FieldType.Keyword)
    private String name;

    @Field(store = true, type = FieldType.Text)
    //Text可以分词 ik_smart=粗粒度分词 ik_max_word 为细粒度分词
    private String address;

    @Field(index = false, store = true, type = FieldType.Integer)
    private Integer age;

    @Field(index = false, store = true, type = FieldType.Date, format = DateFormat.basic_date_time)
    private Date createTime;

    @Field(type = FieldType.Keyword)
    private String[] courseList; //数组类型 由数组中第一个非空值决定(这里数组和集合一个意思了)

    @Field(type = FieldType.Keyword)
    private List<String> colorList= new ArrayList<>(); //集合类型 由数组中第一个非空值决定

}
